//
//  MovieDetailView.m
//  豆瓣
//
//  Created by lanou3g on 15/12/12.
//  Copyright © 2015年 HaiTeng. All rights reserved.
//

#import "MovieDetailView.h"
#import "UIImageView+WebCache.h"
@interface MovieDetailView ()

@property(nonatomic,strong)UILabel *pingFen;  //评分
@property(nonatomic,strong)UILabel *pingLun; //评论
@property(nonatomic,strong)UILabel *zhiZhuoRen; //制作人

@property(nonatomic,strong)UILabel *FGF;   //分隔符




@end



@implementation MovieDetailView




//重写set方法赋值
- (void)setModelmodel:(MovieModel *)modelmodel
{
    
    if (modelmodel) {
       
        self.title_.text = modelmodel.title;
        self.country_.text = modelmodel.country;
        self.plot_simple_.text = modelmodel.plot_simple;
        self.genres_.text = modelmodel.genres;
        self.runtime_.text = modelmodel.runtime;
        [self.poster_ sd_setImageWithURL:[NSURL URLWithString:modelmodel.poster] placeholderImage:[UIImage imageNamed:@"picholder"]];
        self.rating_count_.text = modelmodel.rating_count;
        self.rating_.text = modelmodel.rating;
        self.release_date_.text = modelmodel.release_date;
        self.actors_.text = modelmodel.actors;
        
        
    }
    
  
    
}









- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self addAllViews];
    }
    
    return self;
    
}





- (void)addAllViews{
    CGFloat Width = self.frame.size.width;
    CGFloat Hight = self.frame.size.height - 64;
    CGFloat X = 10;
    CGFloat Y = 10;
//poster_; //图片
    
    self.poster_  = [[UIImageView alloc] initWithFrame:CGRectMake(X, Y, Width / 3 - 20, Hight / 3 - 30)];
//    self.poster_.backgroundColor = [UIColor redColor];
    [self addSubview:self.poster_];
    
    
    CGFloat MX = CGRectGetMaxX(self.poster_.frame) + 30;
    CGFloat Myh = self.poster_.frame.size.height / 5;
//pingFen //评分
    self.pingFen = [[UILabel alloc] initWithFrame:CGRectMake(MX, Y, 30, 20)];
//    self.pingFen.backgroundColor = [UIColor yellowColor];
    self.pingFen.text = @"评分:";
    self.pingFen.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.pingFen];

//rating_; //分数
    self.rating_ = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.pingFen.frame) + 10, self.pingFen.frame.origin.y, self.pingFen.frame.size.width, self.pingFen.frame.size.height)];
//    self.rating_.backgroundColor = [UIColor cyanColor];
//    self.rating_.text = @"7.1";
    self.rating_.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.rating_];
//FGF  //分隔符
    self.FGF = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.rating_.frame) + 10, self.pingFen.frame.origin.y, 10, self.pingFen.frame.size.height)];
//    self.FGF.backgroundColor = [UIColor whiteColor];
    self.FGF.text = @"//";
    self.FGF.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.FGF];
//rating_count_; //评论人数
    self.rating_count_ = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.FGF.frame) + 15, self.pingFen.frame.origin.y, self.pingFen.frame.size.width+5, self.pingFen.frame.size.height)];
//    self.rating_count_.backgroundColor = [UIColor cyanColor];
//    self.rating_count_.text = @"2222";
    self.rating_count_.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.rating_count_];
//pingLun  //评论
    self.pingLun = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(self.rating_count_.frame), self.pingFen.frame.origin.y, self.pingFen.frame.size.width, self.pingFen.frame.size.height)];
//    self.pingLun.backgroundColor = [UIColor cyanColor];
    self.pingLun.text = @"评论";
    self.pingLun.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.pingLun];
//release_date_; //上映时间
    self.release_date_ = [[UILabel alloc] initWithFrame:CGRectMake(MX, CGRectGetMaxY(self.pingFen.frame), self.frame.size.width - self.pingFen.frame.origin.x, Myh)];
//    self.release_date_.backgroundColor = [UIColor blueColor];
//    self.release_date_.text = @"20140901";
    self.release_date_.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.release_date_];
//runtime_; //时间
    self.runtime_ = [[UILabel alloc] initWithFrame:CGRectMake(MX, CGRectGetMaxY(self.release_date_.frame), self.frame.size.width - self.pingFen.frame.origin.x, Myh)];
//    self.runtime_.backgroundColor = [UIColor redColor];
//    self.runtime_.text = @"126 min";
    self.runtime_.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.runtime_];
//genres_; //分类
    self.genres_ = [[UILabel alloc] initWithFrame:CGRectMake(MX, CGRectGetMaxY(self.runtime_.frame), self.frame.size.width - self.pingFen.frame.origin.x, Myh)];
//    self.genres_.backgroundColor = [UIColor whiteColor];
//    self.genres_.text = @"动作/冒险/刺激";
    self.genres_.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.genres_];
//country_; //国家
    self.country_ = [[UILabel alloc] initWithFrame:CGRectMake(MX, CGRectGetMaxY(self.genres_.frame), self.frame.size.width - self.pingFen.frame.origin.x, Myh)];
//    self.country_.backgroundColor = [UIColor whiteColor];
//    self.country_.text = @"美国|法国";
    self.country_.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.country_];
//zhiZhuoRen; //制作人
    self.zhiZhuoRen = [[UILabel alloc] initWithFrame:CGRectMake(self.poster_.frame.origin.x, CGRectGetMaxY(self.poster_.frame), self.poster_.frame.size.width, 25)];
//    self.zhiZhuoRen.backgroundColor = [UIColor yellowColor];
    self.zhiZhuoRen.text = @"制作人";
    [self addSubview:self.zhiZhuoRen];
//actors_; //制作信息
    self.actors_ = [[UILabel alloc]initWithFrame:CGRectMake(self.poster_.frame.origin.x, CGRectGetMaxY(self.zhiZhuoRen.frame), Width - 20, 50)];
//    self.actors_.backgroundColor = [UIColor grayColor];
//    self.actors_.text = @"几点飞机上来看房价来看的时间发来看电视剧了开发技术的附件里看到手机福利看电视剧了房间都死了快放假了多久";
    self.actors_.font = [UIFont systemFontOfSize:13];
    self.actors_.numberOfLines = 0;
    [self addSubview:self.actors_];
    
    
    
    
    
//QingJie; //电影情节
    self.QingJie = [[UILabel alloc] initWithFrame:CGRectMake(self.poster_.frame.origin.x, CGRectGetMaxY(self.actors_.frame), self.poster_.frame.size.width, self.zhiZhuoRen.frame.size.height)];
    self.QingJie.text = @"电影情节";
    [self addSubview:self.QingJie];
    
    
    
    
//plot_simple_;//简介
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(self.poster_.frame.origin.x, CGRectGetMaxY(self.QingJie.frame), Width - 20, Hight - CGRectGetMaxY(self.QingJie.frame) - 49)];

    _scrollView.contentSize = CGSizeMake(Width - 20, Hight - CGRectGetMaxY(self.QingJie.frame)+ 100);
    _scrollView.pagingEnabled = YES;

    [self addSubview:_scrollView];
    
    
    
    self.plot_simple_ = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, Width - 20, Hight - CGRectGetMaxY(self.QingJie.frame)+100)];
  
    
    self.plot_simple_.font = [UIFont systemFontOfSize:13];
    self.plot_simple_.numberOfLines = 0;
   
    [_scrollView addSubview:self.plot_simple_];






    
    
    


    
    
//    NSLog(@"%lf",self.frame.size.height);
//     NSLog(@"%lf",self.frame.size.width);
    
}

#warning 注意导航栏高度 44 + 20  和 标签栏高度 49
//- (void)layoutSubviews
//{
//    [super layoutSubviews];
////    NSLog(@"---%lf",self.frame.size.height);
////    NSLog(@"---%lf",self.frame.size.width);
//    
// 
//
//
//
//    
//}







@end
